package com.kabigon.tiny.controller;

import cn.hutool.json.JSONObject;
import com.kabigon.tiny.config.sign.Signature;
import com.kabigon.tiny.core.domain.AjaxResult;
import com.kabigon.tiny.core.domain.R;
import com.kabigon.tiny.entity.User;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * demo controller
 * @author xu.biao
 */
@RestController
@RequestMapping("/user")
public class Demo {
    @Signature
    @RequestMapping("/test/{id}")
    public R<String> myController(@PathVariable String id,
                                  @RequestParam String client,
                                  @RequestBody User user) {
        return R.ok(String.join(", ", id, client, user.toString()));
    }

    @RequestMapping("/time")
    public AjaxResult time() {
        JSONObject data = new JSONObject();
        data.putOpt("locadatetime", LocalDateTime.now());
        data.putOpt("long", Long.MAX_VALUE);

        return AjaxResult.success(data);
    }
}
